<!DOCTYPE html>
<html>
<head>
    <title>短信管理</title>
    <include file='public/head'>
	<style>
		.layui-legend-size{font-size:14px !important;}
		.layui-field-padding{border-width: 1px;padding:0 0 5px 10px;}
	</style>
</head>
<body>
	<!-- layui-tab开始 -->
	<div class="layui-tab " lay-filter="demo-tab" >
		<!-- 顶部导航菜单开始 -->
		<div class="layui-tab-nav" >
			<ul class="layui-tab-title">
				{:getNav('sms','admin_index/index')};
				
			</ul>
		</div>	
		<!-- 顶部导航菜单结束 -->
        <div class="layui-col-md12">
            
            <div class="layui-col-md8 layui-col-md-offset2" >
                <blockquote class="layui-elem-quote" style="margin-top:10px;">温馨提示: 短信配置请谨慎修改,避免发送短信错误; 开启了服务商以后请设置相对应的短信参数,否则不能成功发送短信.</blockquote>
                 <!-- 开始 -->
        		<fieldset class="layui-elem-field layui-field-title layui-field-padding" style="padding:20px;margin:20px auto;" >
        		    <legend class="layui-legend-size">短信服务商启用开关</legend>
        		    <form class="layui-form" action="">
        		        <volist name="list" id="vo">
        		            <input type="radio" name="sms_way" value="{$vo.type}" title="{$vo.name}" lay-filter="subsmsmway" <?php if( $vo['type'] == $enabled ) echo 'checked';?> >
        		        </volist>
                    </form>
                    <empty name="list">
                        未安装插件
                    </empty>
        		</fieldset>
        		
        		<!-- 开始 -->
        		<fieldset class="layui-elem-field layui-field-title layui-field-padding" >
        			<legend class="layui-legend-size">短信参数配置</legend>
        			
                    <div class="layui-tab" style="padding-top:10px;">
                        <ul class="layui-tab-title">
                            <volist name="smsConfigList" id="vo" >
                                <li <?php if( $key == $enabled )echo 'class="layui-this"' ?> ><a href="#"  >{$vo['name']}</a></li>
                            </volist>
                        </ul>
                        <div class="layui-tab-content">
                            <volist name="smsConfigList" id='vo' >
                            <div class="layui-tab-item  <?php if( $key == $enabled )echo ' layui-show' ?>  ">
                                {$vo['page']|default=''}
                            </div>
                            </volist>
                        </div>
                        <empty name="smsConfigList">
                            未安装插件
                        </empty>
                    </div>
        		</fieldset>
        		<!-- 结束 -->
                
                
            </div>
        </div>
		
		
		
	</div>
	<!-- layui-tab结束-->
	<include file='public/scripts'>
    
	<script>
	    ;(function(){
	        var form = layui.form;
	        var upload = layui.upload; 
        
            //执行实例
            var uploadInst = upload.render({
                elem: '#img_logo' //绑定元素
                ,url: '{:cmf_plugin_url("SiteConfig://admin_index/logoIcon")}' //上传接口
                ,done: function(res){
                //上传完毕回调
                    layer.msg( res.message , { time:1000 , icon:(res.code ==200 )?1:5 } , function(){
                        if ( res.code == 200 ){
                            $( '#img_logo' ).attr( 'src' , res.data );
                            $( '#logo_icon' ).val( res.data );
                        }
                    } );
                }
                ,error: function(){
                //请求异常回调
                }
            });
            
            //提交默认配置
            form.on( 'radio(subsmsmway)' , function( data ){ 
                let oval = '{$enabled|default="monutain_cattle"}';
                if( oval == data.value ){
                    return false;
                }
                
                layer.confirm( '确定要切换短信服务商吗?' , { title:'操作提示' , icon : 3 } , function(){
                    
                    layer.alert( '更换服务商以后请及时检查相关配置是否正确!', { title: '温馨提示' , icon : 6 }, function(){
                        $.post( '{:cmf_plugin_url("Sms://admin_index/switchon")}' , {config:data.value} , function( res ){
                            layer.msg( res.message , { time:800 , icon : res.code == 200?1:5} , function(){
                                layer.closeAll();
                                window.location.reload();
                            } );
                        } );
                    } );
                    
                } ,
                function(){
                    window.location.reload();
                }
                );
                
            } );
            
            
	        //监听提交
            form.on('submit(sitesave)', function(data){
                //询问框
                layer.confirm('站点配置信息,请谨慎修改,确定要修改吗？', 
                    {
                        btn: ['确定','取消'], //按钮
                        title:"修改提示",
                        icon: 3
                    },
                    function(){
                        $.post( '{:cmf_plugin_url("SiteConfig://admin_index/saveSiteInfo")}' , {data : data.field } , function( res ){
                            layer.msg( res.message , { time: 800 } , function(){
                            } );
                        } );
                    },
                    function(){
                        layer.msg('操作取消');
                        window.location.reload();
                    }
                );
                
                return false;
            });
            
            form.verify({
              domain_name: function(value, item){ //value：表单的值、item：表单的DOM对象
                if(!new RegExp(/(http|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&amp;:/~\+#]*[\w\-\@?^=%&amp;/~\+#])?/).test(value)){
                  return '请输入正确的域名';
                }
              }

            }); 
            
	    })();
	</script>
	



</body>
</html>